const App = getApp();
const navigationBarHeight = (getApp().diygwstatusBarHeight + 44) + 'px'
Page({
    data: {
        keys: '',
        swipers1: [],
        currentIndex1: 0,
        msgs1: [],
        msgs2: [],
        url: App.Config.basePath,

    },

    //弹出提示信息
    showModal(message) {
        App.WxService.showModal({
            title: '友情提示',
            content: message,
            showCancel: !1,
        });
    },
    onShareAppMessage: function () {
    },

    //页面加载
    onLoad(option) {
        if (option) {
            this.setData({
                globalOption: option
            })
        }
    },

    //页面显示
    onShow() {
        this.getSwipers1();
        this.getMsgs1();
        this.getMsgs2();

    },

    //页面跳转
    navigateTo(e) {
        App.navigateTo(e.currentTarget.dataset.url, e.currentTarget.dataset);
    },
    getInputValue(e) {
        this.setData({
            keys: e.detail.value
        })
    },

    search(e) {
        if (this.data.keys == '') {
            this.showModal("请输入要搜索的关键词");
            return;
        } else {
            App.globalData.sk=this.data.keys;

            wx.switchTab({
                url:"/pages/pro/index"
            })
        }
    },
    getSwipers1() {
        //调用数据
        var datas = [
            {thumb_url: '/assets/images/pic1.jpg', title: `滑块新闻一`, url: App.renderUrl('', 'index')},
            {thumb_url: '/assets/images/pic2.jpg', title: `滑块新闻二`, url: App.renderUrl('', 'index')},
            {thumb_url: '/assets/images/pic3.jpg', title: `滑块新闻三`, url: App.renderUrl('', 'index')}
        ];
        this.setData({
            swipers1: datas
        });
    },

    getMsgs1() {
        //设置要传递的参数
        let param = {
            loadmsg: `正在加载中`
        };

        App.HttpService.getData(param, "/abouts_List").then(data => { //执行服务器Servlet
            this.setData({
                msgs1: data //把从服务器端得到的值赋值给数组
            });
        });
    },

    getMsgs2() {
        //设置要传递的参数
        let param = {
            f: 1,
            loadmsg: `正在加载中`
        };

        App.HttpService.getData(param, "/products_List").then(data => { //执行服务器Servlet
            this.setData({
                msgs2: data //把从服务器端得到的值赋值给数组
            });
        });
    },

})